.formation-control {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 320px;
  max-height: calc(100vh - 40px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  z-index: 1000;
  border: 2px solid #3498db;
}

.formation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 2px solid #3498db;
  padding-bottom: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.formation-header:hover {
  background: rgba(52, 152, 219, 0.1);
  border-radius: 6px;
  padding: 15px;
  margin: -15px -15px 20px -15px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.collapse-arrow {
  color: #3498db;
  font-size: 0.8em;
  transition: transform 0.3s ease;
}

.collapse-arrow.collapsed {
  transform: rotate(-90deg);
}

.formation-content {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    max-height: 1000px;
    transform: translateY(0);
  }
}

.formation-header h2 {
  margin: 0;
  color: #2c3e50;
  font-size: 1.3em;
}

.formation-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: bold;
}

.formation-status.active {
  background: #2ecc71;
  color: white;
}

.formation-status.inactive {
  background: #95a5a6;
  color: white;
}

.formation-section {
  margin-bottom: 20px;
}

.formation-section h3 {
  margin: 0 0 12px 0;
  color: #34495e;
  font-size: 1em;
  border-left: 3px solid #3498db;
  padding-left: 10px;
}

.formation-toggle {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #3498db;
  background: #ecf0f1;
  color: #2c3e50;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: all 0.3s ease;
}

.formation-toggle.active {
  background: #3498db;
  color: white;
}

.formation-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.program-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.program-item {
  border: 1px solid #ecf0f1;
  border-radius: 8px;
  padding: 12px;
  background: #f8f9fa;
}

.program-btn {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #bdc3c7;
  background: #ecf0f1;
  color: #2c3e50;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: all 0.3s ease;
  margin-bottom: 8px;
}

.program-btn.active {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  border-color: #c0392b;
  animation: pulse-program 2s infinite;
}

.program-btn:hover:not(:disabled) {
  background: #d5dbdb;
  transform: translateY(-1px);
}

.program-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.program-description {
  margin: 0;
  font-size: 0.8em;
  color: #7f8c8d;
  line-height: 1.3;
}

.formation-types {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.formation-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border: 1px solid #bdc3c7;
  background: #ecf0f1;
  color: #2c3e50;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 70px;
}

.formation-type-btn.active {
  background: #3498db;
  color: white;
  border-color: #2980b9;
}

.formation-type-btn:hover:not(:disabled) {
  background: #d5dbdb;
  transform: translateY(-2px);
}

.formation-type-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.formation-icon {
  font-size: 1.5em;
  margin-bottom: 4px;
}

.formation-name {
  font-size: 0.8em;
  font-weight: 600;
}

.parameter-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.parameter-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.parameter-item label {
  min-width: 100px;
  font-size: 0.85em;
  color: #2c3e50;
  font-weight: 500;
}

.parameter-item input[type="range"] {
  flex: 1;
  margin: 0 8px;
}

.parameter-item span {
  min-width: 40px;
  text-align: right;
  font-size: 0.8em;
  color: #7f8c8d;
  font-weight: 600;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #ecf0f1;
}

.status-label {
  font-size: 0.75em;
  color: #7f8c8d;
  margin-bottom: 4px;
}

.status-value {
  font-size: 0.9em;
  font-weight: 600;
  color: #2c3e50;
}

.advanced-toggle {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #bdc3c7;
  background: #ecf0f1;
  color: #2c3e50;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.3s ease;
}

.advanced-toggle:hover {
  background: #d5dbdb;
}

.instructions {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 6px;
  border-left: 4px solid #3498db;
}

.instructions ul {
  margin: 0;
  padding-left: 16px;
  color: #34495e;
}

.instructions li {
  font-size: 0.8em;
  margin-bottom: 6px;
  line-height: 1.3;
}

.instructions strong {
  color: #2c3e50;
}

@keyframes pulse-program {
  0% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
  }
}

/* Scrollbar styling */
.formation-control::-webkit-scrollbar {
  width: 6px;
}

.formation-control::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.formation-control::-webkit-scrollbar-thumb {
  background: #bdc3c7;
  border-radius: 3px;
}

.formation-control::-webkit-scrollbar-thumb:hover {
  background: #95a5a6;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .formation-control {
    position: relative;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: none;
    margin: 20px 0;
    border-radius: 0;
  }

  .formation-types {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }

  .formation-type-btn {
    min-height: 60px;
    padding: 8px 4px;
  }

  .formation-icon {
    font-size: 1.2em;
  }

  .formation-name {
    font-size: 0.7em;
  }
}
